/**
 * Created by arvin on 2017/3/31 0031.
 */

$(document).ready(function(){
    //collapseAll  expandAll
    var html = '<div class="fl expandandcollapse"><i class="treeIcon collapseAll"></i><i class="treeIcon expandAll none"></i></div>'
    var columns=[{
        type:'checkbox',
        fieldIndex:'state',
        fixedCell:true,
        width:40
        },
        {
            title:  html + 'number',
            fieldIndex:'number',
            fixedCell:true,
            width:200,
            tdcss:'tl',
            formater:function(value,row){
                return $('<div class="treenumber"><i class="treeIcon"></i>'+value+'</div>')
            },
            thevents:{
                'click .collapseAll':function(){

                    var $btn=$('table thead .expandandcollapse');
                    $btn.find('.collapseAll').addClass('none')
                    $btn.find('.expandAll').removeClass('none');
                    $('#tree').TreeGrid('collapseAll');
                },
                'click .expandAll':function(){
                    var $btn=$('table thead .expandandcollapse');
                    $btn.find('.collapseAll').removeClass('none')
                    $btn.find('.expandAll').addClass('none');
                    $('#tree').TreeGrid('expandAll');
                }
            }
        },
        {
            title:'name',
            fieldIndex:'name',
            width:100
        },
        {
            title:'age',
            fieldIndex:'age',
            width:100
        },
        {
            title:'address',
            fieldIndex:'address',
            width:400
        },
        {
            title:'phone',
            fieldIndex:'phone',
            width:200
        },
        {
            title:'sex',
            fieldIndex:'sex',
            width:100
        }
    ];
    var datas=[
    { isbeaf:false, floor:0,number:'0100',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:false, floor:1,number:'0110',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
           { isbeaf:true, floor:2,number:'0111',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
    { isbeaf:false, floor:0,number:'0200',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
       { isbeaf:false, floor:1,number:'0210',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
           { isbeaf:true, floor:2,number:'0211',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
       { isbeaf:false, floor:1,number:'0220',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
          { isbeaf:true, floor:2,number:'0221',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
          { isbeaf:true, floor:2,number:'0222',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
    { isbeaf:false, floor:0,number:'0300',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
    { isbeaf:true, floor:0,number:'0400',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
    { isbeaf:false, floor:0,number:'0500',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:false, floor:1,number:'0510',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:true, floor:2,number:'0511',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:false, floor:0,number:'0600',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:false, floor:1,number:'0610',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:true, floor:2,number:'0611',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:false, floor:1,number:'0620',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:true, floor:2,number:'0621',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},
        { isbeaf:true, floor:2,number:'0622',name:'arvin', age:'38',address:'ziwei',phone:'18518518518',sex:'man'},



    ];
    //$('#tree').TreeGrid({
    //    column:columns,
    //    treeIcon:'.treenumber .treeIcon',
    //    data:datas
    //});

    $('#test').Ldap({
        ajax:null,
        items:['arvin','tom'],
    });

})